package generator;

import model.AttributeElement;
import model.ClasseElement;
import model.CompositeElement;
import model.MetaModel;
import codeGenerator.JavaCodeGenerator;

public class GeneratorTester {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		JavaCodeGenerator codeGenerator = new JavaCodeGenerator();
		codeGenerator.generateCodeFor(getModel());
	}

	public static MetaModel getModel() {

		MetaModel metaModel = new MetaModel();

		// Classe Société
		metaModel.add(getSocieteClasseElement());

		// Classe Garage
		metaModel.add(getGarageClasseElement());

		// Classe Reparation
		metaModel.add(getReparationClasseElement());

		// Classe Moto
		metaModel.add(getMotoClasseElement());

		// Classe Voiture
		metaModel.add(getVoitureClasseElement());

		return metaModel;
	}

	public static ClasseElement getSocieteClasseElement() {
		ClasseElement currentClasseElement;
		AttributeElement currentAttributeElement;
		CompositeElement currentCompositeElement;

		currentClasseElement = new ClasseElement("Societe");
		currentClasseElement.setVisibility("public");
		currentClasseElement.setPackage("generated");

		currentAttributeElement = new AttributeElement("nom");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		currentAttributeElement = new AttributeElement("adresse");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		currentCompositeElement = new CompositeElement("garages");
		currentCompositeElement.setMultiplicity("*");
		currentCompositeElement.setType("Garage");
		currentCompositeElement.setVisibility("public");
		currentClasseElement.addComposite(currentCompositeElement);

		return currentClasseElement;
	}

	public static ClasseElement getReparationClasseElement() {
		ClasseElement currentClasseElement;
		AttributeElement currentAttributeElement;

		currentClasseElement = new ClasseElement("Reparation");
		currentClasseElement.setPackage("generated");
		currentClasseElement.setVisibility("public");
		currentClasseElement.setAbstract(true);

		currentAttributeElement = new AttributeElement("motif");
		currentClasseElement.setVisibility("public");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		currentAttributeElement = new AttributeElement("date");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		return currentClasseElement;
	}

	public static ClasseElement getMotoClasseElement() {
		ClasseElement currentClasseElement;
		AttributeElement currentAttributeElement;

		currentClasseElement = new ClasseElement("Moto");
		currentClasseElement.setVisibility("public");
		currentClasseElement.setPackage("generated");
		currentClasseElement.setExtends("Reparation");

		currentAttributeElement = new AttributeElement("sd");
		currentAttributeElement.setType("boolean");
		currentAttributeElement.setDefaultValue("false");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		return currentClasseElement;
	}

	public static ClasseElement getGarageClasseElement() {
		ClasseElement currentClasseElement;
		AttributeElement currentAttributeElement;
		CompositeElement currentCompositeElement;

		currentClasseElement = new ClasseElement("Garage");
		currentClasseElement.setVisibility("public");
		currentClasseElement.setPackage("generated");

		currentAttributeElement = new AttributeElement("nom");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		currentAttributeElement = new AttributeElement("adresse");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		currentCompositeElement = new CompositeElement("reparations");
		currentCompositeElement.setMultiplicity("*");
		currentCompositeElement.setType("Reparation");
		currentCompositeElement.setVisibility("public");
		currentClasseElement.addComposite(currentCompositeElement);

		return currentClasseElement;
	}

	public static ClasseElement getVoitureClasseElement() {
		ClasseElement currentClasseElement;
		AttributeElement currentAttributeElement;

		// Classe Voiture
		currentClasseElement = new ClasseElement("Voiture");
		currentClasseElement.setVisibility("public");
		currentClasseElement.setPackage("generated");
		currentClasseElement.setExtends("Reparation");

		currentAttributeElement = new AttributeElement("ct");
		currentAttributeElement.setType("String");
		currentAttributeElement.setDefaultValue("\"\"");
		currentAttributeElement.setVisibility("public");
		currentClasseElement.addAttribute(currentAttributeElement);

		return currentClasseElement;
	}

}
